<script>
import BaseViewForm from '../components/baseForm/view';
export default {
    props: {

    },
    extends: BaseViewForm,
    data () {
        return {}
    },
    methods: {
        queryCascadingScene: function () {
            const { id } = this;
            return this.$x.get('/userinfo/op/queryCascadingScene', { id });
        },
        queryDetail: function () {
            const { id } = this;
            return this.$x.get('/userinfo/op/detail', { id });
        },
        fetchData: function () {
            const { formName, parentName } = this;

            this.loading = true;
            this.queryCascadingScene().then(({ data = [] }) => {
                if (data.length) {
                    this.formNames = [formName, data[0]];
                } else {
                    this.formNames = formName;
                }
                return this.queryDetail();
            }).then(({ data }) => {
                this.values = this.formatViewData(formName, Object.assign({}, data, { parentName }));
                this.ready = true;
            }).finally(() => {
                this.loading = false;
            });
        }
    }
}
</script>
